
function ParticleSlider(params) {
	var ps = this;

	ps.sliderId = 'particle-slider';


	ps.color = '#fff';


	ps.hoverColor = '#88f';


	ps.width = 0;


	ps.height = 0;


	ps.ptlGap = 0;


	ps.ptlSize = 1;


	ps.slideDelay = 10;


	ps.arrowPadding = 10;


	ps.showArrowControls = true;


	ps.onNextSlide = null;


	ps.onWidthChange = null;


	ps.onHeightChange = null;


	ps.onSizeChange = null;


	ps.monochrome = false;


	ps.mouseForce = 10000;


	ps.restless = true;


	ps.imgs = [];
	
	
	ps.cirPosition = null;   //gyk
	ps.cirNum = 5;   //gyk
	

	/*** value parsing ***/
	if (params) {
		var paramNames = [
			'color',
			'hoverColor',
			'width',
			'height',
			'ptlGap',
			'ptlSize',
			'slideDelay',
			'arrowPadding',
			'sliderId',
			'showArrowControls',
			'onNextSlide',
			'monochrome',
			'mouseForce',
			'restless',
			'imgs',
			'onSizeChange',
			'onWidthChange',
			'onHeightChange'
		];
		for (var i = 0, ii = paramNames.length; i < ii; i++) {
			if (params[paramNames[i]]) ps[paramNames[i]] = params[paramNames[i]];
		}
	}

	/*** HTML references ***/
	ps.$container = ps.$('#' + ps.sliderId);
	ps.$$children = ps.$container.childNodes;
	ps.$controlsContainer = ps.$('.controls');
	ps.$$slides = ps.$('.slide', ps.$('.slides').childNodes, true);
	ps.$controlLeft = null;
	ps.$controlRight = null;
	ps.$canv = ps.$('.draw');

	ps.$srcCanv = document.createElement('canvas');
	ps.$srcCanv.style.display = 'none';
	ps.$container.appendChild(ps.$srcCanv);
	ps.$prevCanv = document.createElement('canvas');
	ps.$prevCanv.style.display = 'none';
	ps.$container.appendChild(ps.$prevCanv);
	ps.$nextCanv = document.createElement('canvas');
	ps.$nextCanv.style.display = 'none';
	ps.$container.appendChild(ps.$nextCanv);
	ps.$overlay = document.createElement('p');
	ps.$container.appendChild(ps.$overlay);
	
	
	//gyk
	ps.$cirCanv=[];
	for(i=0;i<ps.cirNum;i++){
		ps.$cirCanv[i] = document.createElement('canvas');
		ps.$cirCanv[i].style.display = 'none';
		ps.$container.appendChild(ps.$cirCanv[i]);
	}
	ps.imgCir = null;
	
	var cirNameLis=$(".cir_nameLis");  //banner_CompanyName
	for(i=0;i<cirNameLis.length;i++){
		var str=cirNameLis.eq(i).text();
		var arr=str.split("");
		var html="";
		for(j=0;j<arr.length;j++){
			var txt="<span><i class='in'>"+arr[j]+"</i><i class='out'>"+arr[j]+"</i></span>";
			html+=txt;
		}
		cirNameLis.eq(i).html(html);
	}
	
	ps.letterRotate = function(){
		for(i=0;i<cirNameLis.length;i++){
			(function(){
				var ii=i;
				var span=cirNameLis.eq(ii).find("span");
				for(j=0;j<span.length;j++){
					(function(){
						var k=j;
						setTimeout(function(){
							cirNameLis.eq(ii).find("span").eq(k).find("i").toggleClass("in out");
						},k*80)
					})()
				}
			})()
		}
	}
	setInterval(function(){
		ps.letterRotate();
	},2000)
	//gyk
	






	ps.imgControlPrev = null;
	ps.imgControlNext = null;

	if (ps.$$slides.length <= 1) ps.showArrowControls = false;
	if (ps.$controlsContainer && ps.$controlsContainer.childNodes && ps.showArrowControls == true) {
		ps.$controlLeft = ps.$('.left', ps.$controlsContainer.childNodes);
		ps.$controlRight = ps.$('.right', ps.$controlsContainer.childNodes);
		ps.imgControlPrev = new Image();
		ps.imgControlNext = new Image();
		ps.imgControlPrev.onload = function () {
			ps.$prevCanv.height = this.height;
			ps.$prevCanv.width = this.width;
			ps.loadingStep();
		};
		ps.imgControlNext.onload = function () {
			ps.$nextCanv.height = this.height;
			ps.$nextCanv.width = this.width;
			ps.loadingStep();
		};
		ps.imgControlPrev.src = ps.$controlLeft.getAttribute('data-src');
		ps.imgControlNext.src = ps.$controlRight.getAttribute('data-src');
	} else {
		ps.showArrowControls = false;
	}
	
	//gyk
	if($('.cir_glis').length>0){
		ps.$cir = $('.cir_glis').get(0);
		ps.imgCir = new Image();
		ps.imgCir.onload = function () {
			ps.$cirCanv[0].height = this.height;
			ps.$cirCanv[0].width = this.width;
			ps.loadingStep();
		};
		if(window.innerWidth >=768 ){
			ps.imgCir.src = ps.$cir.getAttribute('data-src');
		}else{
			ps.imgCir.src = ps.$cir.getAttribute('data-src-phone');
		}
		
	}
	
	
	
	
	if (ps.width <= 0) ps.width = ps.$container.clientWidth;
	if (ps.height <= 0) ps.height = ps.$container.clientHeight;

	/*** private values (internal use) ***/
	ps.mouseDownRegion = 0;
	ps.colorArr = ps.parseColor(ps.color);
	ps.hoverColorArr = ps.parseColor(ps.hoverColor);
	ps.mx = -1;
	ps.my = -1;
	ps.swipeOffset = 0;
	ps.cw = ps.getCw();
	ps.ch = ps.getCh();
	ps.frame = 0;
	ps.nextSlideTimer = false;
	ps.currImg = 0;
	ps.lastImg = 0;
	ps.imagesLoaded = 0;
	ps.pxlBuffer = { first: null };
	ps.recycleBuffer = { first: null };

	ps.ctx = ps.$canv.getContext('2d');
	ps.srcCtx = ps.$srcCanv.getContext('2d');
	ps.prevCtx = ps.$prevCanv.getContext('2d');
	ps.nextCtx = ps.$nextCanv.getContext('2d');
	
	//gyk
	ps.cirCtx=[];
	for(i=0;i<ps.cirNum;i++){
		ps.cirCtx[i]=ps.$cirCanv[i].getContext('2d');
	}
	
	
	
	
	ps.$canv.width = ps.cw;
	ps.$canv.height = ps.ch;

	/*** extend Array with shuffle function ***/
	ps.shuffle = function () {
		var tmp, rand;
		for (var i = 0, ii = this.length; i < ii; i++) {
			rand = Math.floor(Math.random() * ii);
			tmp = this[i];
			this[i] = this[rand];
			this[rand] = tmp;
		}
	}
	Array.prototype.shuffle = ps.shuffle;

	/***** bind mose events *****/
	/*** canvas - mouseout ***/
	ps.$canv.onmouseout = function () {
		ps.mx = -1;
		ps.my = -1;
		ps.mouseDownRegion = 0;
	}

	/*** canvas - mousemove ***/
	ps.$canv.onmousemove = function (evt) {
		function GetElementPosition(param) {
			var x = 0, y = 0;
			var obj = (typeof param === 'string') ? ps.$(param) : param;
			if (obj) {
				x = obj.offsetLeft;
				y = obj.offsetTop;
				var body = document.getElementsByTagName('body')[0];
				while (obj.offsetParent && obj != body) {
					x += obj.offsetParent.offsetLeft;
					y += obj.offsetParent.offsetTop;
					obj = obj.offsetParent;
				}
			}
			this.x = x;
			this.y = y;
		}

		var divPos = new GetElementPosition(ps.$container);

		ps.mx = evt.clientX - divPos.x + document.body.scrollLeft + document.documentElement.scrollLeft;
		ps.my = evt.clientY - divPos.y + document.body.scrollTop + document.documentElement.scrollTop;
		
		
		//gyk
		if(ps.cirPosition){
			var cirHover=[];
			var cirTrueNum=0;
			for(i=0;i<ps.cirPosition.length;i++){
				cirHover[i]=ps.mx >= ps.cirPosition[i].x && ps.mx < (ps.cirPosition[i].x + ps.$cirCanv[0].width) && ps.my >=ps.cirPosition[i].y && ps.my < (ps.cirPosition[i].y + ps.$cirCanv[0].height)
			}
			for(i=0;i<cirHover.length;i++){
				(function(){
					var j=i;
					if(cirHover[i]==true){
						cirTrueNum++;
						//console.log(cirTrueNum);
						//console.log(j);
						$(".cir_nameLis").eq(j).addClass("active").siblings(".cir_nameLis").removeClass("active");
					}
				})()
			}
			if( cirTrueNum>0 ){
				$("#particle-slider").css({"cursor":"pointer"})
				$(".cir_name").addClass("visi");
			}else{
				$("#particle-slider").css({"cursor":"default"})
				$(".cir_name").removeClass("visi");
				$(".cir_nameLis").removeClass("active");
			}
		}
		
		
		
		
	}

	
	
	



	/*** canvas - mousedown ***/
	ps.$canv.onmousedown = function () {
		if (ps.imgs.length > 1) {
			var region = 0;
			if (ps.mx >= 0 && ps.mx < ps.arrowPadding * 2 + ps.$prevCanv.width) {
				region = -1;
			} else if (ps.mx > 0 && ps.mx > ps.cw - (ps.arrowPadding * 2 + ps.$nextCanv.width)) {
				region = 1;
			}
			ps.mouseDownRegion = region;
		}
		
		
		
		//gyk
//		var cirHover=[];
//		for(i=0;i<ps.cirPosition.length;i++){
//			cirHover[i]=ps.mx >= ps.cirPosition[i].x && ps.mx < (ps.cirPosition[i].x + ps.$cirCanv[0].width) && ps.my >=ps.cirPosition[i].y && ps.my < (ps.cirPosition[i].y + ps.$cirCanv[0].height)
//		}
//		for(i=0;i<cirHover.length;i++){
//			(function(){
//				var j=i;
//				if(cirHover[i]==true){
//					console.log(j);
//				}
//			})()
//		}
		
		
		
	}

	/*** canvas - mouseup ***/
	ps.$canv.onmouseup = function () {
		if (ps.imgs.length > 1) {
			var region = '';
			if (ps.mx >= 0 && ps.mx < ps.arrowPadding * 2 + ps.$prevCanv.width) {
				region = -1;
			} else if (ps.mx > 0 && ps.mx > ps.cw - (ps.arrowPadding * 2 + ps.$nextCanv.width)) {
				region = 1;
			}
			if (region != 0 && ps.mouseDownRegion != 0) {
				if (region != ps.mouseDownRegion) region *= -1;
				if (ps.nextSlideTimer) clearTimeout(ps.nextSlideTimer);
				ps.nextSlide(region);

			}
			ps.mouseDownRegion = 0;
		}
	}

	/*** load images dynamicly ***/
	if (ps.imgs.length == 0) {
		for (var i = 0, ii = ps.$$slides.length; i < ii; i++) {
			var img = new Image();
			ps.imgs.push(img);
			
			if(window.innerWidth >1280 ){
				img.src = ps.$$slides[i].getAttribute('data-src');
			}else if( window.innerWidth >=768 ){
				img.src = ps.$$slides[i].getAttribute('data-src-pad');
			}else{
				img.src = ps.$$slides[i].getAttribute('data-src-phone');
			}
		}
	}
	if (ps.imgs.length > 0) {
		ps.imgs[0].onload = function () {
			ps.loadingStep();
		};
	}

	/*** render frames ***/
	window.requestAnimationFrame(function () { ps.nextFrame(); });
}


var psParticle = function (ps) {
	this.ps = ps;

	this.ttl = null;

	this.color = ps.colorArr;

	this.next = null;
	this.prev = null;


	this.gravityX = 0;


	this.gravityY = 0;


	this.x = Math.random() * ps.cw;


	this.y = Math.random() * ps.ch;

	this.velocityX = Math.random() * 10 - 5;


	this.velocityY = Math.random() * 10 - 5;
}


psParticle.prototype.move = function () {
	var ps = this.ps;
	var p = this;
	if (this.ttl != null && this.ttl-- <= 0) {
		ps.swapList(p, ps.pxlBuffer, ps.recycleBuffer);
		this.ttl = null;
		return;
	}
	var gravityDX = this.gravityX + ps.swipeOffset - this.x;
	var gravityDY = this.gravityY - this.y;
	var gravityDistance = Math.sqrt(Math.pow(gravityDX, 2) + Math.pow(gravityDY, 2));
	var gravityAngle = Math.atan2(gravityDY, gravityDX);
	var gravityForce = gravityDistance * 0.01;
	if (ps.restless == true) {
		gravityForce += Math.random() * 0.1 - 0.05;
	} else {
		if (gravityForce < 0.01) {
			this.x = this.gravityX + 0.25;
			this.y = this.gravityY + 0.25;
		}
	}

	var cursorForce = 0;
	var cursorAngle = 0;

	if (ps.mx >= 0 && ps.mouseForce) {
		var cursorDX = this.x - ps.mx;
		var cursorDY = this.y - ps.my;
		cursorForce = Math.min(ps.mouseForce / (Math.pow(cursorDX, 2) + Math.pow(cursorDY, 2)), ps.mouseForce);
		cursorAngle = Math.atan2(cursorDY, cursorDX);
		if (typeof this.color == 'function') {
			cursorAngle += Math.PI;
			cursorForce *= 0.001 + Math.random() * 0.1 - 0.05;
		}
	}
	else {
		cursorForce = 0;
		cursorAngle = 0;
	}

	this.velocityX += gravityForce * Math.cos(gravityAngle) + cursorForce * Math.cos(cursorAngle);
	this.velocityY += gravityForce * Math.sin(gravityAngle) + cursorForce * Math.sin(cursorAngle);

	this.velocityX *= 0.92;
	this.velocityY *= 0.92;

	this.x += this.velocityX;
	this.y += this.velocityY;

}

/* move Particle to ParticleSlider namespace */
ParticleSlider.prototype.Particle = psParticle;


ParticleSlider.prototype.swapList = function (p, srcList, dstList) {
	var ps = this;

	if (p == null) {
		//p is not defined - create new Particle
		p = new ps.Particle(ps);
	} else {
		//remove p from srcList
		if (srcList.first == p) {
			if (p.next != null) {
				p.next.prev = null;
				srcList.first = p.next;
			}
			else {
				srcList.first = null;
			}
		}
		else {
			if (p.next == null) {
				p.prev.next = null;
			}
			else {
				p.prev.next = p.next;
				p.next.prev = p.prev;
			}
		}
	}

	//add to dstList
	if (dstList.first == null) {
		dstList.first = p;
		p.prev = null;
		p.next = null;
	}
	else {
		p.next = dstList.first;
		dstList.first.prev = p;
		dstList.first = p;
		p.prev = null;
	}
}


ParticleSlider.prototype.parseColor = function (result) {
	var tmp;
	var result = result.replace(' ', '');

	if (tmp = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/.exec(result)) {
		tmp = [parseInt(tmp[1], 16), parseInt(tmp[2], 16), parseInt(tmp[3], 16)];
	} else if (tmp = /^#([\da-fA-F])([\da-fA-F])([\da-fA-F])/.exec(result)) {
		tmp = [parseInt(tmp[1], 16) * 17, parseInt(tmp[2], 16) * 17, parseInt(tmp[3], 16) * 17];
	} else if (tmp = /^rgba\(([\d]+),([\d]+),([\d]+),([\d]+|[\d]*.[\d]+)\)/.exec(result)) {
		tmp = [+tmp[1], +tmp[2], +tmp[3], +tmp[4]];
	} else if (tmp = /^rgb\(([\d]+),([\d]+),([\d]+)\)/.exec(result)) {
		tmp = [+tmp[1], +tmp[2], +tmp[3]];
	} else return null;

	if (isNaN(tmp[3])) {
		(tmp[3] = 1);
	}

	tmp[3] *= 255;

	return tmp;
}


ParticleSlider.prototype.loadingStep = function () {
	var ps = this;
	ps.imagesLoaded++;
	if (ps.imagesLoaded >= 3 || ps.showArrowControls == false) {
		ps.resize();
		if (ps.slideDelay > 0) ps.nextSlideTimer = setTimeout(function () { ps.nextSlide() }, 1000 * ps.slideDelay);
	}
}


ParticleSlider.prototype.$ = function (query, elems, asArray) {
	var ps = this;
	if (query[0] == '.') {
		var elemClass = query.substr(1);
		if (!elems) elems = ps.$$children;
		var result = [];
		for (var i = 0, ii = elems.length; i < ii; i++) {
			if (elems[i].className && elems[i].className == elemClass) result.push(elems[i]);
		}
		if (result.length == 0) {
			return null;
		} else if (result.length == 1 && !asArray) {
			return result[0];
		} else {
			return result;
		}
	} else return document.getElementById(query.substr(1));
}


ParticleSlider.prototype.nextFrame = function () {
	var ps = this;

	if ((ps.mouseDownRegion == 1 && ps.mx < ps.cw / 2) || (ps.mouseDownRegion == -1 && ps.mx > ps.cw / 2)) {
		ps.swipeOffset = (ps.mx - ps.cw / 2);
	} else {
		ps.swipeOffset = 0;
	}

	var p = ps.pxlBuffer.first;
	var next = null;
	while (p != null) {
		next = p.next;
		p.move();
		p = next;
	}

	ps.drawParticles();

	if (ps.frame++ % 25 == 0 && (ps.cw != ps.getCw() || ps.ch != ps.getCh())) {
		var tmpCh = ps.getCh();
		var tmpCw = ps.getCw();
		if (ps.ch != tmpCw) {
			if (typeof ps.onWidthChange === 'function') {
				ps.onWidthChange(ps, tmpCw);
			}
		}
		if (ps.ch != tmpCh) {
			if (typeof ps.onHeightChange === 'function') {
				ps.onHeightChange(ps, tmpCh);
			}
		}
		if (typeof ps.onSizeChange === 'function') {
			ps.onSizeChange(ps, tmpCw, tmpCh);
		}
		ps.resize();
	}

	setTimeout(function () {
		window.requestAnimationFrame(function () { ps.nextFrame(); });
	}, 15);
}


ParticleSlider.prototype.nextSlide = function (count) {
	var ps = this;
	if (ps.nextSlideTimer != null && ps.imgs.length > 1) {
		ps.currImg = (ps.currImg + ps.imgs.length + (count ? count : 1)) % ps.imgs.length;
		ps.resize();
		if (ps.slideDelay > 0) ps.nextSlideTimer = setTimeout(function () { ps.nextSlide() }, 1000 * ps.slideDelay);
	}
	else {
		if (ps.slideDelay > 0) ps.nextSlideTimer = setTimeout(function () { ps.nextSlide() }, 1000 * ps.slideDelay);
	}
	if (typeof ps.onNextSlide === 'function') {
		ps.onNextSlide(ps.currImg);
	}
}


ParticleSlider.prototype.drawParticles = function () {
	var ps = this;

	//ps.ctx.fillStyle = 'rgba(0,0,0,1)';
	//ps.ctx.fillRect(0, 0, ps.cw, ps.ch);

	//for (var i = 0; i < ps.pxls.length; i++) {
	//	if (ps.pxls[i].x >= 0 && ps.pxls[i].x < ps.cw && ps.pxls[i].y >= 0 && ps.pxls[i].y < ps.ch) {
	//		ps.ctx.fillStyle = ((ps.pxls[i].left && ps.mx >= 0 && ps.mx < ps.arrowPadding * 2 + ps.arrowWidth) ||
	//				(ps.pxls[i].right && ps.mx > 0 && ps.mx > ps.cw - (ps.arrowPadding * 2 + ps.arrowWidth))) ? ps.hoverColor : ps.color;
	//		ps.ctx.beginPath();
	//		ps.ctx.arc(ps.pxls[i].x, ps.pxls[i].y, ps.ptlSize, 0, 2 * Math.PI, false);
	//		ps.ctx.closePath();
	//		ps.ctx.fill();
	//	}
	//}

	//return;
	var imageData = ps.ctx.createImageData(ps.cw, ps.ch);
	var actualData = imageData.data;

	var index;
	var X;
	var Y;
	var dX;
	var dY;
	var color;

	var p = ps.pxlBuffer.first;
	while (p != null) {
		X = ~~p.x;
		Y = ~~p.y;

		for (dX = X; dX < X + ps.ptlSize && dX >= 0 && dX < ps.cw; dX++) {
			for (dY = Y; dY < Y + ps.ptlSize && dY >= 0 && dY < ps.ch; dY++) {
				index = (dY * imageData.width + dX) * 4;
				color = typeof p.color == 'function' ? p.color() : p.color;
				actualData[index + 0] = color[0];
				actualData[index + 1] = color[1];
				actualData[index + 2] = color[2];
				actualData[index + 3] = color[3];
			}
		}

		p = p.next;
	}

	imageData.data = actualData;
	ps.ctx.putImageData(imageData, 0, 0);
}

ParticleSlider.prototype.getPixelFromImageData = function (imageData, offsetX, offsetY) {
	var ps = this;

	var result = [];
	for (var x = 0; x < imageData.width; x += ps.ptlGap + 1) {
		for (var y = 0; y < imageData.height; y += ps.ptlGap + 1) {
			i = (y * imageData.width + x) * 4;

			if (imageData.data[i + 3] > 0) {
				result.push({
					x: offsetX + x,
					y: offsetY + y,
					color: (ps.monochrome == true ?
						[ps.colorArr[0], ps.colorArr[1], ps.colorArr[2], ps.colorArr[3]] :
						[imageData.data[i], imageData.data[i + 1], imageData.data[i + 2], imageData.data[i + 3]])
				});
			}
		}
	}
	return result;
}


ParticleSlider.prototype.init = function (shuffe) {
	var ps = this;
	if (ps.imgs.length > 0) {
		ps.$srcCanv.width = ps.imgs[ps.currImg].width;
		ps.$srcCanv.height = ps.imgs[ps.currImg].height;
		
		ps.srcCtx.clearRect(0, 0, ps.$srcCanv.width, ps.$srcCanv.height);
		ps.srcCtx.drawImage(ps.imgs[ps.currImg], 0, 0);
		var tmpParticles = ps.getPixelFromImageData(
			ps.srcCtx.getImageData(0, 0, ps.$srcCanv.width, ps.$srcCanv.height),
			~~((ps.cw / 2) - (ps.$srcCanv.width / 2)),
			~~((ps.ch / 2) - (ps.$srcCanv.height / 2))
		);
		
		if (ps.showArrowControls == true) {
			ps.prevCtx.clearRect(0, 0, ps.$prevCanv.width, ps.$prevCanv.height);
			ps.prevCtx.drawImage(ps.imgControlPrev, 0, 0);
			var prevParticles = ps.getPixelFromImageData(
				ps.prevCtx.getImageData(0, 0, ps.$prevCanv.width, ps.$prevCanv.height),
				ps.arrowPadding,
				~~(ps.ch / 2 - ps.$prevCanv.height / 2)
			);

			for (var i = 0, ii = prevParticles.length; i < ii; i++) {
				prevParticles[i].color = function () {
					return ps.mx >= 0 && ps.mx < ps.arrowPadding * 2 + ps.$prevCanv.width ? ps.hoverColorArr : ps.colorArr;
				};
				tmpParticles.push(prevParticles[i]);
			}

			ps.nextCtx.clearRect(0, 0, ps.$nextCanv.width, ps.$nextCanv.height);
			ps.nextCtx.drawImage(ps.imgControlNext, 0, 0);
			var nextParticles = ps.getPixelFromImageData(
				ps.nextCtx.getImageData(0, 0, ps.$nextCanv.width, ps.$nextCanv.height),
				ps.cw - ps.arrowPadding - ps.$nextCanv.width,
				~~(ps.ch / 2 - ps.$nextCanv.height / 2)
			);
			for (var i = 0, ii = nextParticles.length; i < ii; i++) {
				nextParticles[i].color = function () {
					return ps.mx > 0 && ps.mx > ps.cw - (ps.arrowPadding * 2 + ps.$nextCanv.width) ? ps.hoverColorArr : ps.colorArr;
				};
				tmpParticles.push(nextParticles[i]);
			}
			
			
		}
		
		
			
		//gyk
		ps.cirPosition=[{
			"x":~~((ps.cw / 2) - (ps.$srcCanv.width / 2) +(ps.$srcCanv.width*0.7315) ),
			"y":~~((ps.ch / 2) - (ps.$srcCanv.height / 2) +(ps.$srcCanv.height*0.1268) )
		},{
			"x":~~((ps.cw / 2) - (ps.$srcCanv.width / 2) +(ps.$srcCanv.width*0.4577) ),
			"y":~~((ps.ch / 2) - (ps.$srcCanv.height / 2) +(ps.$srcCanv.height*0.0203) )
		},{
			"x":~~((ps.cw / 2) - (ps.$srcCanv.width / 2) +(ps.$srcCanv.width*0.0247) ),
			"y":~~((ps.ch / 2) - (ps.$srcCanv.height / 2) +(ps.$srcCanv.height*0.4609) )
		},{
			"x":~~((ps.cw / 2) - (ps.$srcCanv.width / 2) +(ps.$srcCanv.width*0.3577) ),
			"y":~~((ps.ch / 2) - (ps.$srcCanv.height / 2) +(ps.$srcCanv.height*0.9442) )
		},{
			"x":~~((ps.cw / 2) - (ps.$srcCanv.width / 2) +(ps.$srcCanv.width*0.6649) ),
			"y":~~((ps.ch / 2) - (ps.$srcCanv.height / 2) +(ps.$srcCanv.height*0.8061) )
		}]
		
		var cirParticles=[];
		for(j=0;j<ps.cirNum;j++){
			ps.cirCtx[j].clearRect(0, 0, ps.$cirCanv[j].width, ps.$cirCanv[j].height);
			ps.cirCtx[j].drawImage(ps.imgCir, 0, 0);
			cirParticles[j] = ps.getPixelFromImageData(
				ps.cirCtx[j].getImageData(0, 0, ps.$cirCanv[j].width, ps.$cirCanv[j].height),
				ps.cirPosition[j].x,
				ps.cirPosition[j].y
			);
			for (var i = 0, ii = cirParticles[j].length; i < ii; i++) {
				cirParticles[j][i].color = function () {
					//console.log($co);
					return ps.parseColor("#004793");
				};
				tmpParticles.push(cirParticles[j][i]);
			}
		}
		
		
			
			
			
		
		

		if (ps.currImg != ps.lastImg || shuffe == true) {
			tmpParticles.shuffle();
			ps.lastImg = ps.currImg;
		}

		var p = ps.pxlBuffer.first;
		for (var i = 0, ii = tmpParticles.length; i < ii; i++) {
			var target = null;
			if (p != null) {
				target = p;
				p = p.next;
			} else {
				ps.swapList(ps.recycleBuffer.first, ps.recycleBuffer, ps.pxlBuffer);
				target = ps.pxlBuffer.first;
			}
			target.gravityX = tmpParticles[i].x;
			target.gravityY = tmpParticles[i].y;
			target.color = tmpParticles[i].color;
		}

		while (p != null) {
			p.ttl = ~~(Math.random() * 10);
			p.gravityY = ~~(ps.ch * Math.random());
			p.gravityX = ~~(ps.cw * Math.random());
			p = p.next;
		}

		ps.$overlay.innerHTML = ps.$$slides[ps.currImg].innerHTML;
	}
}


ParticleSlider.prototype.getCw = function () {
	var ps = this;
	return Math.min(document.body.clientWidth, ps.width, ps.$container.clientWidth);
}


ParticleSlider.prototype.getCh = function () {
	var ps = this;
	return Math.min(document.body.clientHeight, ps.height, ps.$container.clientHeight);
}


ParticleSlider.prototype.resize = function () {
	var ps = this;
	ps.cw = ps.getCw();
	ps.ch = ps.getCh();
	ps.$canv.width = ps.cw;
	ps.$canv.height = ps.ch;
	ps.init(true);
}


ParticleSlider.prototype.setColor = function (color) {
	var ps = this;
	ps.colorArr = ps.parseColor(color);
}


ParticleSlider.prototype.setHoverColor = function (color) {
	var ps = this;
	ps.hoverColorArr = ps.parseColor(color);
}

ParticleSlider.prototype.requestAnimationFrame = function (callback) {
	var ps = this;

	var fnAnimFrame = (
		window.requestAnimationFrame ||
		window.webkitRequestAnimationFrame ||
		window.mozRequestAnimationFrame ||
		window.oRequestAnimationFrame ||
		window.msRequestAnimationFrame ||
		function (/* function */ callback) {
			window.setTimeout(callback, 1000 / 60);
		}
	);
	fnAnimFrame(callback);
};